{% extends "admin/common_base.html" %}

{% block main %}
<div class="main">
  <div class="container typecho-dashboard">
    <div class="typecho-page-title">
      <h2>网站概要</h2>
    </div>
    <div class="row typecho-page-main">
      <div class="col-mb-12 welcome-board" role="main">
        <p>目前有
          <em>1</em> 篇文章，
          <em>1</em> 个分类。
          <br>点击下面的链接快速开始:</p>

        <ul id="start-link" class="clearfix">
          <li>
            <a href="/admin/wirte/post">撰写新文章</a>
          </li>
          <li>
            <a href="/admin/options/general">系统设置</a>
          </li>
          <li>
              <a href="/admin/options/general">清除缓存</a>
          </li>
        </ul>
      </div>

      <div class="col-mb-12 col-tb-4" role="complementary">
        <section class="latest-link">
          <h3>最近发布的文章</h3>
          <ul>
            <li>
              <span>2.4</span>
              <a href="http://www.typecho.local/index.php/archives/1/" class="title">欢迎使用 Typecho</a>
            </li>
          </ul>
        </section>
      </div>

      <div class="col-mb-12 col-tb-4" role="complementary">
        <section class="latest-link">
          <h3>最受欢迎的文章</h3>
          <ul>
            <li>
              <span>1</span>
              <a target="_blank" href="http://www.typecho.local/index.php/archives/1/#comment-1" class="title">
                欢迎加入 Typecho 大家族
              </a>
            </li>
          </ul>
        </section>
      </div>

      <div class="col-mb-12 col-tb-4" role="complementary">
        <section class="latest-link">
          <h3>官方最新日志</h3>
          <div id="typecho-message">
            <ul>
              <li>读取中...</li>
            </ul>
          </div>
        </section>
      </div>
    </div>
  </div>
</div>
{% endblock %}

{% block footer %}
<script>
  $(document).ready(function () {
      var ul = $('#typecho-message ul'), cache = window.sessionStorage,
          html = cache ? cache.getItem('feed') : '',
          update = cache ? cache.getItem('update') : '';

      if (!!html) {
          ul.html(html);
      } else {
          html = '';
          $.get('http://www.typecho.local/index.php/action/ajax?do=feed', function (o) {
              for (var i = 0; i < o.length; i++) {
                  var item = o[i];
                  html += '<li><span>' + item.date + '</span> <a href="' + item.link + '" target="_blank">' + item.title
                      + '</a></li>';
              }

              ul.html(html);
              cache.setItem('feed', html);
          }, 'json');
      }

      function applyUpdate(update) {
          if (update.available) {
              $('<div class="update-check message error"><p>'
                  + '您当前使用的版本是 %s'.replace('%s', update.current) + '<br />'
                  + '<strong><a href="' + update.link + '" target="_blank">'
                  + '官方最新版本是 %s'.replace('%s', update.latest) + '</a></strong></p></div>')
                  .insertAfter('.typecho-page-title').effect('highlight');
          }
      }

      if (!!update) {
          applyUpdate($.parseJSON(update));
      } else {
          $.get('http://www.typecho.local/index.php/action/ajax?do=checkVersion', function (o, status, resp) {
              applyUpdate(o);
              cache.setItem('update', resp.responseText);
          }, 'json');
      }
  });

</script>
{% endblock %}